package com.spark.lola.mapper.statistics;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.spark.lola.statistics.dto.FindLogisticsDto;
import com.spark.lola.statistics.entity.StatisticsDriver;
import com.spark.lola.support.mybatis.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

/**
 * @author: Zhi-peng wang
 * @date: 2020/05/14 13:49
 * 驾驶员货运总量统计信息mapper
 **/
@Mapper
public interface StatisticsDriverMapper extends BaseMapper<StatisticsDriver> {

    IPage<StatisticsDriver> findPage(Page<StatisticsDriver> page, @Param("groupType") Integer groupType, @Param(Constants.WRAPPER) Wrapper<StatisticsDriver> wrapper);

    @Select("select * from statistics_driver where driver_id=#{driverId} and create_date=#{createDate}")
    StatisticsDriver findByDriverIdAndCreateDate(long driverId, Date createDate);

    @Select("select * from statistics_driver where create_date=#{createDate}")
    List<Long> findHaveByDriverIdAndCreateDate(Date createDate);

    @Delete("delete from statistics_driver where find_in_set(id,#{ids})<>0")
    void deleteByIds(String ids);

    List<StatisticsDriver> findByFindType(FindLogisticsDto<?> findLogisticsDto);
}
